<?php
    $host="localhost";
    $port=3306;
    $socket="";
    $user="root";
    $password="";
    $dbname="petAmigo";
    $dbhandle = "";

function connetSQL($host, $user, $password, $dbname)
{
    $dbhandle = mysql_connect($host, $user, $password) 
        or die("Unable to connect to MySQL");
    return $dbhandle;
}

function SelectQuery($sql, $dbname, $dbhandle)
{
    //$sql = "Select * from Dogs";
    
    $selected = mysql_select_db($dbname,$dbhandle) 
    or die("Could not select databasename");
    
    $retval = mysql_query( $sql, $dbhandle);
    
    if(! $retval )
    {
      die('Could not get data: ' . mysql_error());
    }
    
    while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
    {
        echo " ID :{$row['DogId']}  <br> ".
             "Name: {$row['Name']} <br> ".
             "House id: {$row['HouseId']} <br> ".
             "--------------------------------<br>";
    } 
    //echo "Fetched data successfully\n";
    
    
}

function insertQueryForDogs($dbhandle)
{
    //$sql = "insert into Dogs values(6,'test',4)";
    $dbname = 'petAmigo';
    
       
    mysql_select_db($dbname);
    $retval = mysql_query( $sql, $dbhandle );
    if(! $retval )
    {
      die('Could not enter data: ' . mysql_error());
    }
    //echo "Entered data successfully\n";

}

function closeConnection($dbhandle)
{
    mysql_close($dbhandle);
    
}

$dbhandle = connetSQL($host, $user, $password, $dbname);
//insertQuery($sql, $dbname, $dbhandle);
//SelectQuery($sql, $dbname, $dbhandle);
//closeConnection($dbhandle);

?>